package com.tzxs.pay.main.base;

import android.view.View;
import android.widget.Toast;

/**
 * 用户名 huhh
 * 时间  2018/9/7
 * 功能模块 防抖动点击
 **/
public abstract class OnMultiClickListener implements View.OnClickListener {
    public static final int MIN_DELAY_CLICK = 2000;
    private long lastClickTime = 0;
    private Toast toast;

    @Override
    public void onClick(View v) {
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime > MIN_DELAY_CLICK) {
            lastClickTime = currentTime;
            onMultiClick(v);
        } else {
            if (toast == null)
                toast = Toast.makeText(v.getContext(), "操作过快，稍后再试", Toast.LENGTH_SHORT);
            toast.show();
        }
    }

    public abstract void onMultiClick(View view);
}